<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 4.3.2 or newer
 *
 * @package        CodeIgniter
 * @author        ExpressionEngine Dev Team
 * @copyright    Copyright (c) 2006, EllisLab, Inc.
 * @license        http://codeigniter.com/user_guide/license.html
 * @link        http://codeigniter.com
 * @since        Version 1.0
 * @filesource
 */

/**
 * CodeIgniter Common Helpers
 *
 * @package        CodeIgniter
 * @subpackage    Helpers
 * @category    Helpers
 * @author        Ario Sutomo
 * @link        
 */


if (! function_exists('m')) {
    function m($s) {
		$CI =& get_instance();
		$fb = FirePHP::getInstance(TRUE);
		$fb->log($s);
	}
}


if (! function_exists('timeDiff')) {
	function timeDiff($firstTime,$lastTime) {
		// convert to unix timestamps
		$firstTime=strtotime($firstTime);
		$lastTime=strtotime($lastTime);

		// perform subtraction to get the difference (in seconds) between times
		$timeDiff=$lastTime-$firstTime;

		// return the difference
		return $timeDiff;
	}
}


/**
   * Generate Dropdown
   *
   * @access public
   * @param array $objA Option Name
   * @param array $objB Option Value
   * @param string $objC Dropdown Field Name
   * @param string $objD Dropdown Selected Value
   * @param string $objE pre-selected
   * @param string $objF additional attributes
   * @param string $objG additional attributes
   * @return string $html_result
   *
   */
  function crtDropDown($objA,$objB,$objC,$objD='',$objE='',$objF='')
  {
    $html_result  = "<select id='$objC' name='$objC' $objF>\n";
    $html_result .= ($objE <> "") ? "<option value=''>$objE</option>" : "";

    foreach($objA as $k=>$v)
    {
      if($objD == $objB[$k]) $selected = "selected";
      else $selected = "";
      $html_result .= "<option value='".$objB[$k]."' $selected>$v</option>\n";
    }

    $html_result .= "</select>\n";

    return $html_result;
  }


if (! function_exists('addSeconds')) {
	function addSeconds($tgl) {
		//format tgl yg diminta: "1/2/2013 8:52 AM"
		$a = explode(" ", $tgl);
		if (isset($a[1])) {
			$a[1] = $a[1].':00';
			$tgl = implode(" ", $a);			
		}

		return $tgl;
	}
}

